package com.common;

import com.service.pcFixService;

import java.util.List;

/**
 * Created by ztc on 16-3-18.下午4:54
 */
public class pageBean {
    //当前页数
    private int curPage;
    //上一页
    private int previousPage;
    //下一页
    private int nextPage;
    //总页数
    private int allPage;
    //总条数
    private int recordCount;
    //页大小
    private int pageSize;
    private pcFixService pcS;
    public pageBean(int curPage, int pageSize) {
        pcS=new pcFixService();
        this.curPage = (curPage-1)*pageSize;
        this.pageSize = pageSize;
        this.recordCount=pcS.recordCount();
        this.allPage=recordCount%pageSize==0?recordCount/pageSize:recordCount/pageSize+1;
    }

    public int getCurPage() {
        return curPage/pageSize;
    }

    public int getPreviousPage() {
        //System.out.println("p "+(curPage/pageSize+1>0?curPage/pageSize+1:1));
        return curPage/pageSize>0?curPage/pageSize:1;
    }

    public int getNextPage() {
        //System.out.println("n "+(curPage/pageSize+1+1<=allPage?curPage/pageSize+1+1:allPage));
        return curPage/pageSize+1+1<=allPage?curPage/pageSize+1+1:allPage;
    }

    public int getAllPage() {
        return allPage;
    }

    public int getRecordCount() {
        return recordCount;
    }

    public List<pcBean> getList() {
        return pcS.getLimit(curPage,pageSize);
    }
}
